package com.jacobson.huobi.mvp.presenter

import com.jacobson.core.di.annotation.ActivityScope
import com.jacobson.core.mvp.BasePresenter
import com.jacobson.huobi.common.expansion.applySchedulersIoMain
import com.jacobson.huobi.common.expansion.onRespResult
import com.jacobson.huobi.common.expansion.onResponseResult
import com.jacobson.huobi.common.expansion.onResult
import com.jacobson.huobi.entities.evt.VipRechargeSubmitEvt
import com.jacobson.huobi.mvp.contract.HomeContract
import com.jacobson.huobi.mvp.contract.VipContract
import okhttp3.MultipartBody
import javax.inject.Inject

@ActivityScope
class VipPresenter @Inject constructor(
    view: VipContract.View,
    model: VipContract.Model
) : BasePresenter<VipContract.View, VipContract.Model>(view, model), VipContract.Presenter {

    override fun loadRechargeSupportList(vipLevel: Int) {
        model.loadRechargeSupportList(vipLevel)
            .applySchedulersIoMain()
            .onRespResult(view) {resp ->
                view?.onRechargeSupportResp(resp)
            }
    }

    override fun loadRechargeCost(rechargeSupportId: Int) {
        model.loadRechargeCost(rechargeSupportId)
            .applySchedulersIoMain()
            .onResponseResult(view) {resp ->
                view?.onRechargeCostResp(resp)
            }
    }

    override fun vipUpload(file: MultipartBody.Part, width: Int) {
        model.vipUpload(file, width)
            .applySchedulersIoMain()
            .onResponseResult(view) {resp ->
                view?.onVipUploadResp(resp)
            }
    }

    override fun rechargeSubmit(rechargeSubmitEvt: VipRechargeSubmitEvt) {
        model.rechargeSubmit(rechargeSubmitEvt)
            .applySchedulersIoMain()
            .onResponseResult(view) {resp ->
                view?.onRechargeSubmitResp(resp)
            }
    }
}
